Skip to content

fix: truncate user text on char boundaries to stop lint panic - #71

Merged
fohara merged 1 commit into
mainfrom
fix/note-truncation-char-boundary
Aug 27, 2026
Merged

fix: truncate user text on char boundaries to stop lint panic#71
fohara merged 1 commit into
mainfrom
fix/note-truncation-char-boundary

Conversation

@fohara

@fohara fohara commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #70.

ContextualNote::truncated_text sliced note text by byte index, so rendering a W_NOTE_TOO_LONG warning panicked whenever byte 57 fell inside a multi-byte character. The repro from the issue (a 233-byte note with an em dash at bytes 55..58) crashed lash lint with exit 101.

This adds a lash_types::text module with two helpers: floor_char_boundary (walks back to a valid boundary, same contract as the still-unstable std method) and truncate_with_ellipsis. truncated_text is now a thin wrapper over the latter.

The audit the issue asked for turned up the same latent panic in five more places, all switched to the helpers:

  • diff display line truncation (&line[..120] in diff_display.rs)
  • ASCII graph title truncation (ascii_graph.rs)
  • TUI logo title truncation (logo.rs)
  • TUI theme selector names (&name[..27] in theme_selector.rs)
  • agent token-budget truncation (tokens.rs)

Search snippets (search.rs) and lash list descriptions (list.rs) already walked back to a boundary by hand; both now call the shared helper instead of carrying their own copy.

Tests: new unit tests in lash-types cover the exact scenario from the issue (em dash at bytes 55..58, truncated_text(60)) plus exhaustive cut-point sweeps over accented, CJK, and emoji text. The full workspace suite passes, and the issue's two-file repro now lints cleanly: lash index && lash lint reports W_NOTE_TOO_LONG and exits 0.

A multi-byte char straddling the truncation index made truncated_text
panic (#70). Adds lash_types::text helpers and fixes five more sites
with the same byte-index slicing.
@fohara
fohara merged commit fbce16b into main Aug 27, 2026
24 checks passed
@fohara
fohara deleted the fix/note-truncation-char-boundary branch August 27, 2026 20:32
fohara added a commit that referenced this pull request Aug 27, 2026
0.5.0 was prepared on 2026-08-15 but the tag was never pushed, so the
release never shipped. Re-date and include today's lint-panic fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lash lint panics when a long note has a multi-byte char at the truncation boundary

1 participant